import request from "@/utils/request";

export default {
  //角色列表-条件分页查询
  getPageList(pageNo, pageSize, searchObj) {
    return request({
      url: `/sysRole/${pageNo}/${pageSize}`,
      method: "get",
      //如果普通对象参数写法，则需要用params，params: 对象参数名称
      //如果使用对象参数写法，则需要用data，data: 对象参数名称
      params: searchObj,
    });
  },

  //角色删除
  removeById(id) {
    return request({
      url: `/sysRole/${id}`,
      method: "delete",
    });
  },

  //角色新增
  save(role){
    return request({
        url: `/sysRole`,
        method: 'post',
        data: role
      })
  },

  //角色修改
  getById(id) {
    return request({
      url: `/sysRole/${id}`,
      method: 'get'
    })
  },
  
  update(role) {
    return request({
      url: `/sysRole`,
      method: 'put',
      data: role
    })
  },

  //批量删除
  batchRemove(idList) {
    return request({
      url: `/sysRole`,
      method: `delete`,
      data: idList
    })
  },

  getRoles(userId) {
    return request({
      url: `/sysRole/toAssign/${userId}`,
      method: 'get'
    })
  },
  
  assignRoles(assginRoleVo) {
    return request({
      url: `/sysRole/doAssign`,
      method: 'post',
      data: assginRoleVo
    })
  },
};
